<?php

class indexController extends BaseController
{

    public function __init()
    {
        //此控制器初始化时，执行代码

    }


// 新首页 根据数据库记录判断有无上传
    public function index()
    {
        go('/student/index');
    }


// 老师登录
    public function login()
    {
        if (IS_POST()) {
            $r = db('users')->where('name=? and password=?', [I('username'), md5(I('password'))])->fetch();
            if ($r['id']) {
                SS('auth', $r); //打上登录成功标志
                die('成功');
            }
        }
        // 若已经登录过，依据身份跳转到对应界面
        GS('auth')['identity'] === '教师' ? go('/teacher/setup') : null;
        GS('auth')['identity'] === '管理员' ? go('/super/index') : null;
        // 否则显示登录界面
        $this->title = '管理登录';

    }

// 退出登录
    function exit() {
        CS(); //清空session
        M('setups')->del(getroom()); //删除数据记录
        go('/index/login'); //跳转到登录页
    }



// 学生注册
    public function Register()
    {
        if (PG_POST) {
            $v['name']     = I('name');
            $v['class_id'] = GS('setup')['class_id'];
            $v['site']     = getSite();
            $r             = db('students')->add($v);
            $r ? die('注册成功') : die('失败,此座位已注册过');
        }
        $set = GS('setup');
        if(!$set){
            flashMsg('/index/login','班级未设定');
        }
        $r = db('classes')->where('id=?',$set['class_id'])->fetch('name');
        $this->bjName=$r['name'];
        // else
        $this->title = '注册';
    }

    public function super(){
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16103;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16084;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16084;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16084;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16098;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16076;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16076;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16100;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16087;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16103;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16076;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16076;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16076;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16076;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16111;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16116;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16098;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16087;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16087;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16080;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16098;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16058;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16074;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16076;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16075;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16075;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16075;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16075;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16074;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16058;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16097;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16097;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16097;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16111;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16111;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16089;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16093;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16086;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16093;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16082;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16086;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16108;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16108;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16108;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16107;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16108;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16108;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16119;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16119;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16119;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16109;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16109;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16109;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16109;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16109;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16058;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16108;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16109;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16109;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16108;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16109;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16109;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16108;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16097;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16104;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16097;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16104;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16116;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16112;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16100;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16104;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16107;');
// db('students')->query('update tb_students set [game_point]=[game_point]+1 where [id]=16116;');
// db('students')->query('update tb_students set [game_point]=[game_point]+2 where [id]=16100;');
// db('students')->query('update tb_students set [game_point]=[game_point]+2 where [id]=16076;');
// db('students')->query('update tb_students set [game_point]=[game_point]+2 where [id]=16089;');
// db('students')->query('update tb_students set [game_point]=[game_point]+2 where [id]=16064;');
// db('students')->query('update tb_students set [game_point]=[game_point]+2 where [id]=16074;');
// db('students')->query('update tb_students set [game_point]=[game_point]+2 where [id]=16094;');
// db('students')->query('update tb_students set [game_point]=[game_point]+2 where [id]=16116;');
// db('students')->query('update tb_students set [game_point]=[game_point]+2 where [id]=16097;');
// db('students')->query('update tb_students set [game_point]=[game_point]+2 where [id]=16075;');
// db('students')->query('update tb_students set [game_point]=[game_point]+2 where [id]=16080;');
// db('students')->query('update tb_students set [game_point]=[game_point]+2 where [id]=16098;');
// db('students')->query('update tb_students set [game_point]=[game_point]+2 where [id]=16074;');
// db('students')->query('update tb_students set [game_point]=[game_point]+2 where [id]=16076;');
// db('students')->query('update tb_students set [game_point]=[game_point]+2 where [id]=16058;');
// db('students')->query('update tb_students set [game_point]=[game_point]+2 where [id]=16075;');
// db('students')->query('update tb_students set [game_point]=[game_point]+2 where [id]=16097;');
// db('students')->query('update tb_students set [game_point]=[game_point]+2 where [id]=16116;');
// db('students')->query('update tb_students set [game_point]=[game_point]+2 where [id]=16108;');
// db('students')->query('update tb_students set [game_point]=[game_point]+2 where [id]=16083;');
// db('students')->query('update tb_students set [game_point]=[game_point]+2 where [id]=16058;');
// db('students')->query('update tb_students set [game_point]=[game_point]+2 where [id]=16108;');
// db('students')->query('update tb_students set [game_point]=[game_point]+2 where [id]=16108;');
// db('students')->query('update tb_students set [game_point]=[game_point]+2 where [id]=16102;');
// db('students')->query('update tb_students set [game_point]=[game_point]+2 where [id]=16104;');
// db('students')->query('update tb_students set [game_point]=[game_point]+2 where [id]=16088;');
// db('students')->query('update tb_students set [game_point]=[game_point]+2 where [id]=16097;');
// db('students')->query('update tb_students set [game_point]=[game_point]+2 where [id]=16088;');
// db('students')->query('update tb_students set [game_point]=[game_point]+2 where [id]=16096;');
// db('students')->query('update tb_students set [game_point]=[game_point]+2 where [id]=16096;');
// db('students')->query('update tb_students set [game_point]=[game_point]+2 where [id]=16090;');
// db('students')->query('update tb_students set [game_point]=[game_point]+2 where [id]=16107;');
// db('students')->query('update tb_students set [game_point]=[game_point]+2 where [id]=16104;');
// db('students')->query('update tb_students set [game_point]=[game_point]+2 where [id]=16104;');
// db('students')->query('update tb_students set [game_point]=[game_point]+2 where [id]=16106;');
// db('students')->query('update tb_students set [game_point]=[game_point]+2 where [id]=16107;');
// db('students')->query('update tb_students set [game_point]=[game_point]+3 where [id]=16097;');
// db('students')->query('update tb_students set [game_point]=[game_point]+3 where [id]=16073;');
// db('students')->query('update tb_students set [game_point]=[game_point]+3 where [id]=16060;');
// db('students')->query('update tb_students set [game_point]=[game_point]+3 where [id]=16110;');
// db('students')->query('update tb_students set [game_point]=[game_point]+3 where [id]=16105;');
// db('students')->query('update tb_students set [game_point]=[game_point]+3 where [id]=16074;');
// db('students')->query('update tb_students set [game_point]=[game_point]+3 where [id]=16116;');
// db('students')->query('update tb_students set [game_point]=[game_point]+3 where [id]=16078;');
// db('students')->query('update tb_students set [game_point]=[game_point]+3 where [id]=16069;');
// db('students')->query('update tb_students set [game_point]=[game_point]+3 where [id]=16089;');
// db('students')->query('update tb_students set [game_point]=[game_point]+3 where [id]=16100;');
// db('students')->query('update tb_students set [game_point]=[game_point]+3 where [id]=16103;');
// db('students')->query('update tb_students set [game_point]=[game_point]+3 where [id]=16090;');
// db('students')->query('update tb_students set [game_point]=[game_point]+3 where [id]=16099;');
// db('students')->query('update tb_students set [game_point]=[game_point]+3 where [id]=16074;');
// db('students')->query('update tb_students set [game_point]=[game_point]+3 where [id]=16076;');
// db('students')->query('update tb_students set [game_point]=[game_point]+3 where [id]=16094;');
// db('students')->query('update tb_students set [game_point]=[game_point]+3 where [id]=16075;');
// db('students')->query('update tb_students set [game_point]=[game_point]+3 where [id]=16096;');
// db('students')->query('update tb_students set [game_point]=[game_point]+3 where [id]=16058;');
// db('students')->query('update tb_students set [game_point]=[game_point]+3 where [id]=16076;');
// db('students')->query('update tb_students set [game_point]=[game_point]+3 where [id]=16087;');
// db('students')->query('update tb_students set [game_point]=[game_point]+3 where [id]=16075;');
// db('students')->query('update tb_students set [game_point]=[game_point]+3 where [id]=16087;');
// db('students')->query('update tb_students set [game_point]=[game_point]+3 where [id]=16089;');
// db('students')->query('update tb_students set [game_point]=[game_point]+3 where [id]=16093;');
// db('students')->query('update tb_students set [game_point]=[game_point]+3 where [id]=16066;');
// db('students')->query('update tb_students set [game_point]=[game_point]+3 where [id]=16082;');
// db('students')->query('update tb_students set [game_point]=[game_point]+3 where [id]=16086;');
// db('students')->query('update tb_students set [game_point]=[game_point]+3 where [id]=16083;');
// db('students')->query('update tb_students set [game_point]=[game_point]+3 where [id]=16058;');
// db('students')->query('update tb_students set [game_point]=[game_point]+3 where [id]=16108;');
// db('students')->query('update tb_students set [game_point]=[game_point]+3 where [id]=16062;');
// db('students')->query('update tb_students set [game_point]=[game_point]+3 where [id]=16109;');
// db('students')->query('update tb_students set [game_point]=[game_point]+3 where [id]=16119;');
// db('students')->query('update tb_students set [game_point]=[game_point]+3 where [id]=16057;');
// db('students')->query('update tb_students set [game_point]=[game_point]+3 where [id]=16089;');
// db('students')->query('update tb_students set [game_point]=[game_point]+3 where [id]=16086;');
// db('students')->query('update tb_students set [game_point]=[game_point]+3 where [id]=16096;');
// db('students')->query('update tb_students set [game_point]=[game_point]+3 where [id]=16088;');
// db('students')->query('update tb_students set [game_point]=[game_point]+3 where [id]=16090;');
// db('students')->query('update tb_students set [game_point]=[game_point]+3 where [id]=16082;');
// db('students')->query('update tb_students set [game_point]=[game_point]+3 where [id]=16117;');
// db('students')->query('update tb_students set [game_point]=[game_point]+3 where [id]=16106;');
// db('students')->query('update tb_students set [game_point]=[game_point]+3 where [id]=16116;');


        pd("游戏积分找回成功2！");
    }



}
